// pages/goods_list/goods_list.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    pageConfig: {
      pagenum: 1,
      pagesize: 10,
    },
    total: 0,
    active: 0,
    // 默认图片
    img:'https://ww1.sinaimg.cn/large/007rAy9hgy1g24by9t530j30i20i2glm.jpg'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad({ cid }) {
    this.getGoodsList(cid);
  },
  async getGoodsList(id) {
    const { message } = await wx.http({
      url: `/goods/search?cid=${id}`,
    });
    const { total, goods } = message;
    this.setData({
      list: goods,
      total,
    });
  },
  onChange(e) {
    console.log(e);
  },
  // 给子组件传值
  gotoSearch() {
    wx.navigateTo({
      url: "/pages/search/search",
    });
  },
});
